<template>
  <div class="control-item">
    <div class="control-header">
      <span class="control-name">当前状态</span>
    </div>
    <div class="control-body">
      <div class="control-section">
        <!-- 光标样式 -->
        <div class="control-item show-lines">
          <div class="control-title flex-between">
            <span>光标样式</span>
            <span class="reset" @click="resetItem('lineNum')">重置</span>
          </div>
          <div class="control-content">
            <a-select
              :default-value="params.params.tabItem.borderType"
              @change="setTabItem"
              class="justify-select"
            >
              <a-select-option value="line"> 直线 </a-select-option>
              <a-select-option value="radius"> 圆角 </a-select-option>
            </a-select>
          </div>
        </div>
        <!-- 字体配置 -->
        <fontControl
          :fontData.sync="params.params.tabItem.fontCss"
          @resetFontCss="resetFontCss"
          :showAlign="false"
        ></fontControl>
        <!-- 当前状态颜色 -->
        <colorControl
          :color.sync="params.params.tabItem.borderColor"
          title="当前状态颜色"
          @reset="resetBorderColor"
          @change="setBorderColor"
        ></colorControl>
      </div>
    </div>
  </div>
</template>

<script>
import { diyTopPic } from "@/components/DiyNew/diy/dataConfig/config.js";

import uploadImg from "@/components/DiyNew/uploadImg/index.vue";
import fontControl from "@/components/DiyNew/diy/baseControl/fontControl/index.vue";
import colorControl from "@/components/DiyNew/diy/baseControl/colorControl/index.vue";

export default {
  name: "diyTopPicTabItemControl",
  components: {
    fontControl,
    colorControl,
    uploadImg,
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {};
  },
  watch: {},
  computed: {},
  methods: {
    // 设置tab属性
    setTabItem(e) {
      let tabItem = JSON.parse(JSON.stringify(this.params.params.tabItem));
      tabItem.borderType = e;
      this.setWithActionItem(tabItem, "tabItem");
    },
    setWithActionItem(e, key) {
      this.$setWithAction(this.params, key, e);
    },
    // 重置文字设置
    resetFontCss() {
      let data = Object.assign({}, diyTopPic);
      this.$set(
        this.params.params.tabItem,
        "fontCss",
        data.params.params.tabItem.fontCss
      );
    },
    // 点击重置按钮
    resetItem(type) {
      let data = Object.assign({}, diyTopPic);
      this.$set(this.params.params, type, data.params[type]);
    },
    // 设置当前状态颜色
    setBorderColor(e) {
      // this.$set(this.params.params.tabItem, "borderColor", e);
      let tabItem = JSON.parse(JSON.stringify(this.params.params.tabItem));
      tabItem.borderColor = e;
      this.setWithActionItem(tabItem, "tabItem");
    },
    // 重置当前状态颜色
    resetBorderColor() {
      this.$set(this.params.params.tabItem, "borderColor", "");
    },
  },
};
</script>

<style lang="scss" scoped>
.control-item {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  .control-header {
    width: 100%;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px 14px 24px;
    span {
      font-size: 12px;
      color: #8c8c8c;
    }
    .control-name {
      font-size: 14px;
      font-weight: 600;
      color: #000000;
    }
    span:nth-child(2) {
      cursor: pointer;
    }
  }
  .control-body {
    width: 100%;
    padding-bottom: 20px;
    .control-section {
      width: 228px;
      margin: 0 auto;
      text-align: center;
      .control-item {
        width: 100%;
        .control-title {
          padding: 24px 0 14px 0;
          font-size: 12px;
          color: #000000;
          text-align: left;
        }
        .control-content {
          .example-list {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            .example-item {
              width: 70px;
              height: 53px;
              background: #f6f7f9;
              border-radius: 4px;
              margin-right: 6px;
              margin-bottom: 6px;
              display: flex;
              justify-content: center;
              align-items: center;
              cursor: pointer;
              img {
                width: 66px;
              }
            }
            .example-item:last-child {
              margin-right: 0;
            }
            .active {
              border: 2px solid #1890fc;
            }
          }
        }
      }
      .show-lines,
      .start-section {
        .flex-between {
          display: flex;
          justify-content: space-between;
          .reset {
            font-size: 12px;
            color: #9e9e9e;
            cursor: pointer;
          }
        }
        .control-content {
          display: flex;
          align-items: center;
          .justify-select {
            width: 100%;
            height: 100%;
            ::v-deep .ant-select-selection--single {
              height: 100%;
              border: 0 none;
              background: #f2f2f2;
            }
            ::v-deep .ant-select-selection__rendered {
              line-height: 40px;
            }
          }
        }
      }
      .split-line {
        .flex-between {
          display: flex;
          justify-content: space-between;
          .reset {
            font-size: 12px;
            color: #9e9e9e;
            cursor: pointer;
          }
        }
        .control-content {
          .line-style {
            display: flex;
            align-items: center;
            .color-select {
              width: 48px;
              height: 40px;
              background: #f6f7f9;
              border-radius: 4px;
              margin-right: 8px;
            }
            .color-input {
              width: 86px;
              height: 40px;
              background: #f6f7f9;
              border-radius: 4px;
              margin-right: 8px;
            }
            .color-width {
              width: 78px;
              height: 40px;
              background: #f6f7f9;
              border-radius: 4px;
            }
          }
        }
      }
    }
  }
}
</style>
